package com.tbm.common.util;

import com.tbm.common.constant.SessionConstant;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * Created by Administrator on 2017/8/30.
 */
public class JurisdictionUtil {

    public static boolean isValid(){
        Object object = getSession().getAttribute(SessionConstant.STATE);
        boolean result = false;
        if(object instanceof Boolean){
            result = (boolean) object;
        }
        return result;
    }

    /**
     * session
     * @return

     */
    public static HttpSession getSession(){
        //Subject currentUser = SecurityUtils.getSubject();
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        HttpSession httpSession = request.getSession();
        return httpSession;
    }
}
